package il.ac.braude.sona.gui.forms.questions;

import java.awt.Component;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
/**
 * The FormQuestion is an abstract class define the necessary methods of all Question in our applicaion
 *  
 * @author Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 */
public abstract class FormQuestion extends JPanel {
	/**
	 * mePanel - the panel for question
	 */
	private JPanel mePanel;
	/**
	 * isNecessary - boolean define if the question is necessary to fill
	 */
	private boolean isNecessary = false;

	/**
	 * Constructs the FormQuestion.
	 * 
	 * @param axis - axis of the question
	 */
	public FormQuestion(int axis) {
		setOpaque(false);
		mePanel = new JPanel();
		mePanel.setLayout(new BoxLayout(mePanel,axis));
		add(mePanel, 0);
	}
	/**
	 * Constructs the FormQuestion.
	 * 
	 * @param axis - axis of the question
	 * @param isNecessary - boolean define if the question is necessary to fill
	 */
	public FormQuestion(int axis,boolean isNecessary) {
		setOpaque(false);
		this.isNecessary=isNecessary;
		mePanel = new JPanel();
		mePanel.setLayout(new BoxLayout(mePanel,axis));
		add(mePanel, 0);
	}
	
	/**
	 * Set the default answer that will returned for this question
	 * 
	 * @param defaultAnswer - the default answer to set
	 */
	public abstract void setDefaultAnswer(Object defaultAnswer);
	/**
	 * Returns the default answer for this question
	 * 
	 * @return defaultAnswer - the default answer of this question
	 */
	public abstract Object getAnswer();
	/**
	 * check whether the question is necessary to fill
	 * 
	 * @return isNecessary - true if necessary, false if not necessary
	 */
	public boolean isNecessary() {return isNecessary;}
	/**
	 * Set whether the question is necessary to fill
	 * 
	 * @param isNecessary - true if necessary, false if not necessary
	 */
	public void setNecessary(boolean isNecessary) {
		this.isNecessary = isNecessary;
	}
	@Override
	public Component add(Component comp) {
		mePanel.add(comp);
		return comp;
	}
	/**
	 * marks the question in red color if not field and isNecessary 
	 */
	public void markQuestion() {

	}
	/**
	 * remove mark of question
	 */
	public void unmarkQuestion() {

	}
}
